home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / batch / library / batutl2 / signal.asm < prev    next >
Assembly Source File  |  1988-04-20  |  3KB  |  115 lines

  1. TITLE    SIGNAL    12-28-84    [4-16-88]
  2. ;Toad Hall Disassembly, tweak
  3. ;Don't really understand what this is trying to do
  4. ;(except wait for kbd input and beep periodically).
  5. ;But I've faithfully (kinda) kept with the spirit of the
  6. ;original code.
  7.  
  8. LF    EQU    0AH
  9. CR    EQU    0DH
  10. ;
  11. ;INITIAL VALUES :    CS:IP    0000:0100
  12. ;            SS:SP    0000:FFFF
  13. CodeSeg    SEGMENT
  14.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  15.     ORG    100H
  16.  
  17. Signal    proc    near
  18.     JMP    SHORT    Start
  19.  
  20. prompt    DB    'Press any key to continue.......$'
  21. CrLf    db    CR,LF,'$'
  22. byte_124    DB    20H
  23. wconst_127    dw    06A0H        ;magic sound numbers
  24. wconst_129    dw    0350H
  25. wconst_12B    dw    06A0H
  26. wconst_12D    dw    0350H
  27.  
  28. Start:
  29.     MOV    SI,80H            ;point to PSP cmd line
  30.     CMP    BYTE PTR [SI],0        ;cmd line length 0?
  31.     JNZ    L014A            ; nope, continue
  32.      mov    DX,offset prompt    ;'press any key to continue...'
  33.      MOV    AH,9            ;display string
  34.      INT    21H
  35.      JMP    SHORT    KbdLup_16E    ;get kbd input, exit
  36.  
  37. L014A:    xor    cx,cx            ;clear msb
  38.     MOV    CL,[SI]            ;get cmd line length byte
  39.     DEC    CL            ;adjust
  40.     DEC    CL            ;-2
  41.     INC    SI            ;bump cmd line ptr 2
  42.     INC    SI
  43.     MOV    BL,[SI]            ;snarf char
  44.     MOV    byte_124,BL        ;save here
  45.  
  46. Lup15A:    INC    SI            ;bump cmd line ptr
  47.     MOV    DL,[SI]            ;get cmd line char
  48.     CMP    DL,byte_124        ;same as first cmd line char?
  49.     JNZ    L0168            ; nope, go display it
  50.      CALL    Do_CrLf
  51.      LOOP    Lup15A            ;retry
  52.  
  53. L0168:    MOV    AH,2            ;display output in DL
  54.     INT    21H
  55.     LOOP    Lup15A            ;retry
  56.  
  57. ;beep until kbd input, then exit
  58. KbdLup_16E:
  59.     MOV    AH,0BH            ;check kbd input status
  60.     INT    21H
  61.     CMP    AL,0FFH            ;anything there?
  62.     JZ    Read_Kbd        ; yep, read it, exit
  63. ;make some flashy sounds
  64.     MOV    BX,wconst_127        ;constant 06A0H
  65.     CALL    Beep
  66.     MOV    BX,wconst_129        ;constant 0350H
  67.     CALL    Beep
  68.     MOV    BX,wconst_12B        ;constant 06A0H
  69.     CALL    Beep
  70.     MOV    BX,wconst_12D        ;constant 0350H
  71.     CALL    Beep
  72.     xor    cx,cx            ;nice delay counter
  73. Lup1A4:    NOP
  74.     LOOP    Lup1A4
  75.     JMP    SHORT    KbdLup_16E    ;check kbd again
  76.  
  77. Read_Kbd:
  78.     MOV    AH,7            ;kbd input w/o echo
  79.     INT    21H
  80. ;no document with this, so donno WHAT to do with that char!
  81. ;Should we return it as an Errorlevel?  Why not...
  82.     mov    ah,4CH            ;terminate process
  83.     int    21H            ;done
  84. Signal    endp
  85.  
  86.  
  87. Do_CrLf    proc    near
  88.     mov    dx,offset CrLf
  89.     mov    ah,9            ;display string
  90.     int    21H
  91.     RET
  92. Do_CrLf    endp
  93.  
  94.  
  95. Beep    proc    near
  96.     MOV    AL,0B6H            ;enable sound reg?
  97.     OUT    43H,AL
  98.     mov    ax,bx            ;sound freq in bx
  99.     OUT    42H,AL
  100.     MOV    AL,AH            ;freq msb?
  101.     OUT    42H,AL
  102.     IN    AL,61H            ;get sound reg value
  103.     MOV    AH,AL            ;save a sec
  104.     OR    AL,3
  105.     OUT    61H,AL            ;sound on
  106.     SUB    CX,CX            ;nice delay loop
  107. Lup1D2:    LOOP    Lup1D2
  108.     MOV    AL,AH            ;restore sound reg value
  109.     OUT    61H,AL            ;sound off
  110.     RET
  111. Beep    endp
  112.  
  113. CodeSeg    ENDS
  114.     END    Signal
  115.